package com.ruoyi.web.controller.warning;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.warning.domain.entity.Region;
import com.ruoyi.warning.domain.query.RegionQuery;
import com.ruoyi.warning.service.IRegionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chenhc
 * @since 2025-04-01
 */
@RestController
@RequestMapping("/region")
@Api(tags = "核心区域", description = "用于处理核心区域相关操作的控制器")
public class RegionController {
    @Resource
    private IRegionService RegionService;
    @ApiOperation("获取所有区域")
    @GetMapping(value = "/getAllRegion")
    public R getAllRegion(RegionQuery query)
    {
        return R.ok(RegionService.getAllRegion(query));
    }
    @ApiOperation("获取区域详情")
    @GetMapping(value = "/getRegionDetail/{id}")
    public R getRegionDetail(@PathVariable String id) {
        return R.ok(RegionService.getById(id));
    }
    @ApiOperation("新增或修改区域")
    @PostMapping(value = "/addOrUpdateRegion")
    public R addRegion(Region region) {
        return R.ok(RegionService.addOrUpdateRegion(region));
    }
    @ApiOperation("删除区域")
    @DeleteMapping(value = "/deleteRegion/{id}")
    public R deleteRegion(@PathVariable String id) {
        return R.ok(RegionService.deleteRegion(id));
    }
}
